import re

# file path
file_path = 'test.txt'
# new block
new_block_content = """diff_normal_player = {
    no_supply_grace = 36
	industrial_capacity_dockyard = 10000
	industrial_capacity_factory = 10000
	army_core_defence_factor = 10
	army_speed_factor = 2
	supply_consumption_factor = -0.9
	air_range_factor = 20
	naval_speed_factor = 20
}"""

# read and relace
with open(file_path, 'r', encoding='utf-8') as file:
    file_data = file.read()

# Use regular expressions to find and replace all matching blocks
# Note: The regular expression here matches content starting with 'block = {' and ending with the next '}', including newlines.
# Make sure this doesn't accidentally match something you don't want to replace
updated_data = re.sub(r'(diff_normal_player = \{.*?\})', new_block_content, file_data, flags=re.DOTALL)

# write back
with open(file_path, 'w', encoding='utf-8') as file:
    file.write(updated_data)

print("All blocks is replaced!")